
local btn = lv.btn_create( lv.scr_act() );

lv.obj_set_size( btn, 100, 50 );

lv.obj_center( btn );

local btn_label = lv.label_create( btn );

lv.label_set_text( btn_label, "Click me!" );

lv.obj_center( btn_label );

local info_label = lv.label_create( lv.scr_act() );

lv.label_set_text( info_label, "The last button event:\nNone" );

lv.obj_add_event_cb( btn, lv.LV_EVENT_ALL, function( e )

	local code = lv.event_get_code( e );

	if lv.LV_EVENT_PRESSED == code then

		lv.label_set_text( info_label, "The last button event:\nLV_EVENT_PRESSED" );

	elseif lv.LV_EVENT_CLICKED == code then

		lv.label_set_text( info_label, "The last button event:\nLV_EVENT_CLICKED" );

	elseif lv.LV_EVENT_LONG_PRESSED == code then

		lv.label_set_text( info_label, "The last button event:\nLV_EVENT_LONG_PRESSED" );

	elseif lv.LV_EVENT_LONG_PRESSED_REPEAT == code then

		lv.label_set_text( info_label, "The last button event:\nLV_EVENT_LONG_PRESSED_REPEAT" );
	end

end )
